package com.tuniondata.netty.client;

import com.tuniondata.netty.bean.MessageDecoder;
import com.tuniondata.netty.bean.MessageEncoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;

public class ChildChannelHandler extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new IdleStateHandler(20, 10, 0));
        ch.pipeline().addLast(new MessageDecoder());
        ch.pipeline().addLast(new MessageEncoder());
        ch.pipeline().addLast(new ApiClientHandler());
    }
}
